package com.citycloud.ccuap.tc.admin.config;

import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * oauth2异常配置信息
 */
@AutoConfigureBefore(ResourceServerConfiguration.class)
public class SecurityConfiguration {

    /**
     * oauth2的client配置
     */
    @ConfigurationProperties(prefix = "security.oauth2.client")
    @Bean
    public SecurityConfig.SecurityOauth2ClientConfig securityOauth2ClientConfig() {
        return new SecurityConfig.SecurityOauth2ClientConfig();
    }

    /**
     * oauth2的resource配置
     *
     * @return
     */
    @ConfigurationProperties(prefix = "security.oauth2.resource")
    @Bean
    public SecurityConfig.SecurityOauth2ResourceConfig securityOauth2ResourceConfig() {
        return new SecurityConfig.SecurityOauth2ResourceConfig();
    }

    /**
     *
     */
    @Bean
    public Auth2ResponseExceptionTranslator auth2ResponseExceptionTranslator(final SecurityConfig.SecurityOauth2ClientConfig clientConfig) {
        return new Auth2ResponseExceptionTranslator(clientConfig);
    }

    @Bean
    public SecurityAuthenticationEntryPoint securityAuthenticationEntryPoint(final SecurityConfig.SecurityOauth2ClientConfig clientConfig) {
        return new SecurityAuthenticationEntryPoint(clientConfig);
    }


}
